<?php

class ActivatePetAction extends CAction
{
	public function run()
	{
		$pet=Pet::loadPet($_POST['id']);
		if($pet===null)
			throw new CHttpException(404,'cannot find pet['.$_POST['id'].']');
		$user=&$this->getController()->getUser();
		if($user===null)
			throw new CHttpException(500,'cannot find user['.Yii::app()->user->name.']');
		if($user->name!=$pet->userName)
			throw new CHttpException(401, "user[$user->name] doesn't equal petUserName[$pet->userName] petid=$pet->id");

		$user->activatePet($pet);
		$this->getController()->renderPartial('ActivatePet',array('result'=>'设置成功'));
	}
}

?>
